package com.itheima.coll;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo03 {

    public static void main(String[] args) {
        Collection<String> list= new ArrayList<>();

        list.add("test");
        list.add("test");
        list.add("张三");
        list.add("李四");
        list.add("test");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if(next.equals("test")){
              //  list.remove("test");
               // iterator.remove();
                list.add("hahah");
            }
        }
        System.out.println(list);

    }
}
